<?php $this->Html->addCrumb('Disputes'); ?>
<style type="text/css">
td p span{color:#00B050;}
td.vendor h2 {font-size:20px; color: #00B050;}
</style>
<div class="global-title">Dispute</div>
<?php if(!empty($disputelist)): ?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" class="check-out-table">
	<tr>
            <th bgcolor="#ccc">Case ID</th>
            <th bgcolor="#ccc">Opened On</th>
            <th bgcolor="#ccc">Expires On</th>
            <th bgcolor="#ccc">Seller ID</th>
            <th bgcolor="#ccc">Status</th>
            <th bgcolor="#ccc">Action</th>
        </tr>
	
	<?php foreach($disputelist as $dispute):?>
        <tr id="row_<?php echo $dispute['Dispute']['id'];?>">
                <td style="vertical-align: middle;">
              <a href="javascript:void(0);" controller="products" action="viewdispute"
                       ElmID="<?php echo $dispute['Dispute']['id']; ?>" onclick='showPop(this)'> <?php echo $dispute['Dispute']['id'];?></a>
                
                </td>
                <td style="vertical-align: middle;">
                 <?php echo date('d-m-Y',  strtotime($dispute['Dispute']['open_date']));?>
                </td>
                <td style="vertical-align: middle;">
                    <?php echo date('d-m-Y',  strtotime($dispute['Dispute']['expire_date']));?>
                </td>
                <td style="vertical-align: middle;">
                <?php echo $dispute['Seller']['username'];?>
                </td>
                <td style="vertical-align: middle;">
                <?php echo $dispute['Dispute']['status'];?>
                </td>
                <td style="vertical-align: middle;">
               <a href="javascript:void(0);" controller="messages" action="dispute_message" title="Respond"
                       ElmID="<?php echo $dispute['Dispute']['id']; ?>"  ElmID2="2" onclick='showPop(this)'>Respond</a>&nbsp;|&nbsp;
               <a href="javascript:void(0);" controller="messages" action="dispute_message" title="History"
                       ElmID="<?php echo $dispute['Dispute']['id']; ?>" ElmID2="1" onclick='showPop(this)'>History</a><br />
               <a href="javascript:void(0);"  id="<?php echo $dispute['Dispute']['id']; ?>" class="Mediation_dispute">Mediation</a>
                       &nbsp;|&nbsp;
               <a href="javascript:void(0);" controller="products" action="addnote_dispute" title="Add a Note"
                       ElmID="<?php echo $dispute['Dispute']['id']; ?>"  onclick='showPop(this)'>Add a Note</a><br />
               <a href="javascript:void(0);"  id="<?php echo $dispute['Dispute']['id']; ?>" class="close_dispute">Close</a>
                </td>
        </tr>
        <?php
        $comments = $this->requestAction('/products/getdisputenote/'.$dispute['Dispute']['id']);
        //pr($comments);
        if(!empty ($comments)){
?>
       <tr    class="fullrow">
            <td colspan="6"  style="background: none repeat scroll 0pt 0pt BlanchedAlmond;text-align: left;"><b>My Note:</b>
    <?php

        foreach($comments as $comment) {
        echo $comment['Disputenote']['note'];echo"<br/>";
        //$j++;

        }
?>
</td></tr>
        <?php

        }
        ?>
            <?php
            endforeach;
            ?>			
</table>
<?php else:?>
<br /><br />
<h2>Your Dispute list is empty.</h2>
<br /><br /><br />
<?php endif;?>
<?php  //echo $html->script(array("jquery.min.js")); ?>
<script type="text/javascript">
    jQuery(document).ready(function(){

        jQuery(".close_dispute").click(function(){

            var mid=jQuery(this).attr('id');
            
            jQuery.ajax({
                type: 'GET',
                url : baseurl+'products/close_dispute/'+mid,
                dataType: 'html',
                success: function(data){
                    window.location.reload();
                }
            });

        });
        ///////////////////////mediation
        jQuery(".Mediation_dispute").click(function(){

            var mid=jQuery(this).attr('id');

            jQuery.ajax({
                type: 'GET',
                url : baseurl+'products/mediation_dispute/'+mid,
                dataType: 'html',
                success: function(data){
                    window.location.reload();
                }
            });

        });

    });
</script>